package com.lz.demo5;

/**
 * @ClassName MathematicsMajor
 * @Description 数学专业类
 * @Author 2214361854
 * @Date 2022/5/28 14:55
 * @Version 1.0
 */
public class MathematicsMajor extends Major {
    //20.添加子类独有的属性:数学理论课成绩
    private double mathScore;

    //21.生成子类自己的全参构造
    public MathematicsMajor(double mathScore, double englishScore, double midScore, double finalScore) {
        //这里是在调用父类的构造方法,因为英文 期中 期末 成绩都是在父类那里赋值的
        super(englishScore, midScore, finalScore);
        //在子类的构造方法中只需要给子类的特有属性专业课成绩赋值即可
        this.mathScore = mathScore;
    }

    //22.子类重写父类的getScore(),具体实现总分数的计算
    @Override
    public double getScore(){
        //计算逻辑:总成绩=专业课成绩40%+英文课成绩10%+期中成绩15%+期末成绩35%
        totalScore = mathScore*0.4+englishScore*0.1+midScore*0.15+finalScore*0.35;
        //返回计算好的成绩
        return totalScore;
    }

    //23.重写toString()方法,方便直接查看专业类的所有属性值
    @Override
    public String toString() {
        return "数学专业{" +
                "数学理论课成绩:" + mathScore +
                ",英文课成绩:" + englishScore +
                ",期中成绩:" + midScore +
                ",期末成绩:" + finalScore +
                '}';
    }
}
